﻿

Imports System.Data
Imports VSModel
Imports Cls_Common
Partial Class Control_ThongBao
    Inherits System.Web.UI.UserControl

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Not IsPostBack Then

            BindToGrid()
        End If
    End Sub

    Protected Sub BindToGrid()


        Using _data As New VSEntities
            Dim p = (From q In _data.Announcements Where q.StatusId = 3 And q.PublishedDate <= Now() And (q.eEffectiveDate >= Now() Or q.eEffectiveDate Is Nothing) Order By q.PublishedDate Descending Select q).ToList
            With rptThongBao
                .DataSource = p
                .DataBind()
            End With
        End Using
    End Sub
    Protected Sub rptThongBao_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.RepeaterItemEventArgs) Handles rptThongBao.ItemDataBound
        Dim row = CType(e.Item.DataItem, Announcement)
        Dim hplTitle As HyperLink = e.Item.FindControl("hplTitle")
        hplTitle.Text = row.Title & " - " & CType(row.PublishedDate, Date).ToString("dd/MM/yyyy")
        hplTitle.NavigateUrl = MainDomain & "Page/Announcement/Detail.aspx?Id=" & row.Id

    End Sub
End Class
